package demo1;


interface Shape {
    /*
    //接口当中的成员变量都是 public static final修饰的
    public int a = 1;
    public static int b = 2;
    public static final int c = 3;

    //意味着为常量，大写
    int A = 1;
    int B = 2;
    int C = 3;
*/

    /*
    {}
    static {}
    */
    //接口当中的抽象方法默认都是public abstract修饰的
    void draw();
    //public void draw();
    //public abstract void draw();


    // 不能有方法的实现
    /*public void test() {
        System.out.println("123");
    }*/

    // 有static 或者 define关键字修饰的方法可以实现，JDK8 新引入的
    default public void test1(){
        System.out.println("test1");
    }

    public static void test2() {
        System.out.println("test2");
    }
}



class Rect implements Shape {
    public void draw() {
        System.out.println("矩形！");
    }
}

class Flower implements Shape {
    @Override
    public void draw() {
        System.out.println("❀！");
    }
}



public class Test {
    public static void drawMap(Shape shape) {
        shape.draw();
    }
    public static void main(String[] args) {
        //demo1.Shape shape = new demo1.Shape();//不能被实例化
        Shape shape1 = new Rect();
        Shape shape2 = new Flower();

        drawMap(shape1);
        drawMap(shape2);

        System.out.println("====================");

        Shape[] shapes = {new Rect(),new Flower(),new Rect(),new Flower()};

        for (Shape shape: shapes) {
            //drawMap(x);
            shape.draw();
        }
    }
}
